TEMPLATE = app

QT       += core gui serialport network printsupport

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

# debug编译模式下增加宏定义
CONFIG(debug, debug|release) {
    DEFINES += DEBUG_MODE
    TARGET_DIR = "$${OUT_PWD}/debug"
} else {
    TARGET_DIR = "$${OUT_PWD}/release"
}
PUBLIC_DIR = "$${PWD}/public"


# FWidgets 库
include("$$PWD/src/components/FWidgets/FWidgets.pri")


INCLUDEPATH +=             \
    src/components/        \
    src/views/Workspace/   \
    src/views/Hardware/    \
    src/views/Help/        \
    src/views/Project/     \
    src/views/Tool/        \
    src/views/             \
    src/serveices/         \
    src/stores/            \
    src/utils/             \
    src/3rd/               \
    src/                   


# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

RC_ICONS += \
    public/icons/icon0.ico

# 自动添加 *.h 和 *.cpp 文件，并过滤 build 目录
# 在Unix系统（Linux, macOS）中使用find命令
unix {
    SOURCES += $$system(find . -name "*.cpp" -type f -not -path "./build/*" -not -path "*/build/*")
    HEADERS += $$system(find . -name "*.h" -type f -not -path "./build/*" -not -path "*/build/*")
    FORMS += $$system(find . -name "*.ui" -type f -not -path "./build/*" -not -path "*/build/*")
}
# 在Windows中使用dir命令
win32 {
    SOURCES += $$system(dir /s /b *.cpp | findstr /v /i "\\build\\")
    HEADERS += $$system(dir /s /b *.h | findstr /v /i "\\build\\")
    FORMS += $$system(dir /s /b *.ui | findstr /v /i "\\build\\")
}

RESOURCES += \
    res/fonts.qrc \
    res/imgs.qrc \
    res/trs.qrc

TRANSLATIONS += \
    res/tr/TlvTool_zh_CN.ts

DISTFILES += \
    public/tools/nodejs/predef.js \
    public/tools/python/predef.py


# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

# 依赖库
win32: LIBS +=                                  \
    -ladvapi32 -lsetupapi                       \
    -L$$PWD/lib/QSci   -lqscintilla2_qt5


# 指定使用UTF-8编码
win32-msvc* {
    QMAKE_CXXFLAGS += /utf-8
    QMAKE_CFLAGS += /utf-8
}

# 在构建时执行拷贝
win32 {
    QMAKE_POST_LINK += xcopy /E /I /Y \"$$PUBLIC_DIR\" \"$$TARGET_DIR\" $$escape_expand(\\n\\t)
}
unix {
    QMAKE_POST_LINK += cp -r \"$$PUBLIC_DIR\" \"$$TARGET_DIR\" $$escape_expand(\\n\\t)
}
